//
//  SpecialViewController.m
//  BTCTrade
//
//  Created by tjl on 16/3/29.
//  Copyright © 2016年 tjl. All rights reserved.
//

#import "SpecialViewController.h"
#import "config.h"
#import "Reachability.h"
#import "ColorUtil.h"

@interface SpecialViewController ()

@end

@implementation SpecialViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, DeviceWidth/6, DeviceWidth/2, DeviceWidth/2)];
    
    image.image = [UIImage imageNamed:@"wangluocuowu"];
    
    image.center = CGPointMake(DeviceWidth/2, DeviceWidth/2);
    
    [self.view addSubview:image];
    
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, DeviceWidth, kLineWitdth)];
    line.backgroundColor = [ColorUtil gray_background];
    [self.view addSubview:line];
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 90, 32)];
    
    button.titleLabel.font = [UIFont fontWithName:kFontNameLight size:15];
    
    [button setTitle:stringWithKey(@"again_load_data_title", nil) forState:UIControlStateNormal];
    
    [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(againDownLoadeData) forControlEvents:UIControlEventTouchUpInside];
    
    button.layer.cornerRadius = 3;
    
    button.clipsToBounds = YES;
    
    button.layer.borderWidth = 0.5;
    
    button.layer.borderColor = [UIColor grayColor].CGColor;
    
    button.center = CGPointMake(DeviceWidth/2, CGRectGetMaxY(image.frame)+40);
    
    [self.view addSubview:button];
    
}

/**
 *  重新加载数据
 */
- (void)againDownLoadeData {
    
    Reachability *r = [Reachability reachabilityWithHostName:@"www.apple.com"];
    if (![r currentReachabilityStatus]) {
        [[[UIAlertView alloc] initWithTitle:stringWithKey(@"please_check_networking_status", nil) message:nil delegate:nil cancelButtonTitle:stringWithKey(@"sure", nil) otherButtonTitles: nil] show];
        return;
    }
    
    if (_delegateSpecial && [_delegateSpecial respondsToSelector:@selector(againReloadTheData)]) {
        
        [_delegateSpecial againReloadTheData];
        
        [self.view removeFromSuperview];

    }
    
}

- (void)removeFromSuperview:(UIView *)view {
    
    [self.view removeFromSuperview];
}

- (void)showInView:(UIView *)view {
    
    [view addSubview:self.view];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
